package hot100;

import java.util.Arrays;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/8/28 20:11
 */
public class lc1两数之和 {


    public  static  int[]  solve(int nums[], int target) {
        int ans[] = new int[2];
        Stream<Integer> boxed = IntStream.range(0, nums.length).boxed();
        Integer[] index = boxed.toArray(Integer[]::new);

        Arrays.sort(index, (a, b) -> nums[a] - nums[b]);
        int l = 0, r = nums.length - 1;
        while (l < r) {
         if(nums[index[l]] + nums[index[r]] == target){
             return new int[]{index[l], index[r]};
         }else if(nums[index[l]] + nums[index[r]] < target){
             l++;
         }else{
             r--;
         }
        }
        return null;
    }

    public static void main(String[] args) {
        int nums[] = {3,2,4} , target = 6;
        System.out.println(Arrays.toString(solve(nums,target)));
    }

}
